package n1019;

import java.util.Scanner;

public class Main {
	
	static int a2[]=new int[32000];
	static int a3[]=new int[150000];
	static int b[]=new int[5];
	static int start=1,end=1,a=0;
	static
	{
		int sum=0;
		a2[0]=0;
		int len=1;
		for(int i=1;sum<Integer.MAX_VALUE&&sum>=0;i++)
		{
			int k=(int)Math.log10(i)+1;
			a=a+k;
			sum=sum+a;
			a2[i]=sum;
			int tmp=i;
			int r=0;
			while(tmp>0)
			{
				b[r++]=tmp%10;
				tmp=tmp/10;
			}
			while(r>0)
			{
				r--;
				a3[len++]=b[r];
			}
			end=i-1;
		}
	}
	
	public static void main(String[] args) {
		
		
		Scanner cin=new Scanner(System.in);
		int n=cin.nextInt();
		for(int i=0;i<n;i++)
		{
			int m=cin.nextInt();
			int left=start,right=end;
			while(left<=right)
			{
				int mid=(left+right)>>1;
				if(a2[mid]>m)
				{
					right=mid-1;
				}else if(a2[mid]<m)
				{
					left=mid+1;
				}else{
					left=mid;
					break;
				}
					
			}
			if(a2[left]==m)
			{
				System.out.println(left%10);
			}else{
				System.out.println(a3[m-a2[left-1]]);
			}
		}
	}
}
